<?php
class Payment
{

/*  Random Number Generator Starts */

	function PaymentNumberGenerator($tablename,$field)
	{
				$PaymentNumber="";
				
				function make_seed()
				{
				   list($usec, $sec) = explode(' ', microtime());

				   return (float) $sec + ((float) $usec * 100000);

				}

				while(!$PaymentNumber)

				{

						mt_srand(make_seed());

						$randval = mt_rand();

						$randvalw=rand(65,90);

						$randvalw=chr($randvalw);

						$PaymentNumber=$randvalw."-".$randval;

						

						$select_number="SELECT * FROM $tablename WHERE $field = '$PaymentNumber' ";

						$result_number=mysql_query($select_number) or die("Error In Generating PaymentNumber ".mysql_error());

						$num=mysql_num_rows($result_number);

						if($num>0)

							$PaymentNumber="";

				}

				

				return  $PaymentNumber;

		

		}

/*  Random Number Generator Ends */

}
?>